//
//  RHLocalFaultAlarmDetailVC.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/4/9.
//

#import "RHLocalFaultAlarmDetailVC.h"

@interface RHLocalFaultAlarmDetailVC ()
@property (nonatomic, strong) QMUILabel *alarmCodeValueLab;

@property (nonatomic, strong) QMUILabel *reportDateLab;

@property (nonatomic, strong) QMUILabel *alarmDesTitleLab;

@property (nonatomic, strong) QMUILabel *alarmDesContentLab;
@end

@implementation RHLocalFaultAlarmDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"故障详情".rh_localized;
    [self setupUI];
}

-(void)setupUI
{
    kWeakSelf;
    UIScrollView *scrollView = [[UIScrollView alloc]init];
    scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    scrollView.backgroundColor = CFTabViewBgColor;
    [self.view addSubview:scrollView];
    [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    
    UIView *contentView = kView;
    contentView.backgroundColor = UIColor.whiteColor;
    contentView.layer.cornerRadius = 8;
    [scrollView addSubview:contentView];
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(15, 15, 15, 15));
        make.width.offset(kUI_WINDOW_W-30);
    }];
    
    //上报时间
    self.reportDateLab = [[QMUILabel alloc]init];
    self.reportDateLab.font = kSYSTEMFONT(12);
    self.reportDateLab.textColor = kColorRGBA(63, 68, 67, 0.5);
    self.reportDateLab.textAlignment = NSTextAlignmentRight;
    self.reportDateLab.text = @"2023-07-23 23:23:55";
    [contentView addSubview:self.reportDateLab];
    
    [self.reportDateLab sizeToFit];
    [self.reportDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-15);
        make.top.mas_offset(18);
        make.width.offset(weakSelf.reportDateLab.width+5);
    }];
    
    
    //告警代码
    self.alarmCodeValueLab = [[QMUILabel alloc]init];
    self.alarmCodeValueLab.font = [UIFont systemFontOfSize:14];
    self.alarmCodeValueLab.textColor = [UIColor colorWithHexString:@"3F4443"];
    self.alarmCodeValueLab.textAlignment = NSTextAlignmentLeft;
    self.alarmCodeValueLab.text = @"W1,W2";
    [contentView addSubview:self.alarmCodeValueLab];
    
    [self.alarmCodeValueLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_offset(15);
        make.right.equalTo(self.reportDateLab.mas_left).offset(-15);
    }];
    
    
    QMUILabel *sorceLab = [QMUILabel labelWithText:@"来源:系统提示" font:kSYSTEMFONT(12) textColor:kColorRGBA(63, 68, 67, 0.5)];
    [contentView addSubview:sorceLab];
    [sorceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.alarmCodeValueLab);
        make.top.equalTo(weakSelf.alarmCodeValueLab.mas_bottom).offset(15);
    }];
    
    
    //描述
    self.alarmDesContentLab = [[QMUILabel alloc]init];
    self.alarmDesContentLab.font = [UIFont systemFontOfSize:14];
    self.alarmDesContentLab.textColor = kColorRGBA(63, 68, 67, 0.8);
    self.alarmDesContentLab.lineBreakMode = NSLineBreakByCharWrapping;
    self.alarmDesContentLab.numberOfLines = 0;
    self.alarmDesContentLab.textAlignment = NSTextAlignmentRight;
    self.alarmDesContentLab.text = @"故障了故障了故障了故障了故障了故障了故障了故障了故障了故障了故障了故障了";
    [contentView addSubview:self.alarmDesContentLab];
    
    
    [self.alarmDesContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.top.equalTo(sorceLab.mas_bottom).offset(15);
        make.right.mas_offset(-15);
    }];
    
    //原因分析
    UIView *reasonView = kView;
    reasonView.backgroundColor = CFTabViewBgColor;
    reasonView.layer.cornerRadius = 8;
    [contentView addSubview:reasonView];
    [reasonView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.alarmDesContentLab.mas_bottom).offset(45);
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
    }];
    
    QMUILabel *reasonTitleLab = [QMUILabel labelWithText:@"原因分析" font:kBOLDSYSTEMFONT(13) textColor:kRGB(63, 68, 67)];
    [reasonView addSubview:reasonTitleLab];
    [reasonTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_offset(15);
    }];
    
    QMUILabel *reasonContentLab = [QMUILabel labelWithFont:kSYSTEMFONT(12) textColor:kColorRGBA(63, 68, 67, 0.6) textAligment:NSTextAlignmentLeft];
    reasonContentLab.numberOfLines = 0;
    reasonContentLab.qmui_lineHeight = 20;
    reasonContentLab.text = @"（1）电网没有供电\n（2）交流线路或交流开关断开。";
    [reasonView addSubview:reasonContentLab];
    [reasonContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.equalTo(reasonTitleLab.mas_bottom).offset(15);
        make.bottom.mas_offset(-15);
    }];
    
    //处理建议
    UIView *suggestView = kView;
    suggestView.backgroundColor = CFTabViewBgColor;
    suggestView.layer.cornerRadius  = 8;
    [contentView addSubview:suggestView];
    [suggestView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(reasonView.mas_bottom).offset(20);
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.bottom.mas_offset(-15);
    }];
    
    QMUILabel *suggestTitleLab = [QMUILabel labelWithText:@"处理建议" font:kBOLDSYSTEMFONT(13) textColor:kRGB(63, 68, 67)];
    [suggestView addSubview:suggestTitleLab];
    [suggestTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_offset(15);
    }];
    
    QMUILabel *suggestContentLab = [QMUILabel labelWithFont:kSYSTEMFONT(12) textColor:kColorRGBA(63, 68, 67, 0.6) textAligment:NSTextAlignmentLeft];
    suggestContentLab.numberOfLines = 0;
    suggestContentLab.qmui_lineHeight = 20;
    suggestContentLab.text = @"一般情况下，电网恢复正常后逆变器会重新并网，如果故障反复出现：\n（1）检查电网是否可靠供电；\n（2）检查交流接线是否紧固；\n（3）检查交流接线揽是否接入正确的接线端子(火线是否和N线接反)；\n（4）检查交流断路器是否闭合；\n（5）确认非以上原因，且故障依然存在请联系Renon客户服务中心；";
    [suggestView addSubview:suggestContentLab];
    [suggestContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.equalTo(suggestTitleLab.mas_bottom).offset(15);
        make.bottom.mas_offset(-15);
    }];
}

@end
